home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / programm / GNU_C++ / LIB / CFLIB-11.LZH / src / vdi.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-11-03  |  2.0 KB  |  103 lines

  1. /*
  2.  * vdi.c
  3.  * Hilfs-Routinen rund um das VDI.
  4. */
  5.  
  6. #include "intern.h"
  7.  
  8. int open_vwork(int *w_out)
  9. {
  10.     int    handle;
  11.     int    work_in[11] = {1,1,1,1,1,1,1,1,1,1,2};
  12.  
  13.     handle = gl_phys_handle;
  14.     v_opnvwk(work_in, &handle, w_out);
  15.     return handle;
  16. }
  17.  
  18.  
  19. void set_clipping(int handle, int x, int y, int w, int h, int on)
  20. {
  21.     int clip[4];
  22.  
  23.     clip[0] = x;
  24.     clip[1] = y;
  25.     clip[2] = clip[0]+w-1;
  26.     clip[3] = clip[1]+h-1;
  27.     vs_clip(handle, on, clip);
  28. }
  29.  
  30.  
  31. /*
  32.  * Point-Höhe zu einer Pixel-Höhe ermitteln.
  33. */
  34. int height2pts(int handle, int f_id, int f_height)
  35. {
  36.     int    d, w, h, asked, got, width, height;
  37.     int    pt = -1;
  38.     
  39.     vst_font(handle, f_id);
  40.     vst_height(handle, f_height, &d, &height, &width, &d);
  41.    asked = 99; 
  42.     got = asked;
  43.     while (got <= asked)
  44.     {
  45.         /*
  46.          * Schleife, solange ein kleinerer Font eingestellt werden kann;
  47.          * Abbruch, wenn vst_point() einen /größeren/ Font als angefordert
  48.          * einstellt (und somit auch als tatsächliche Größe zurückliefert)
  49.         */
  50.         asked = got - 1;     /* 1 kleiner als aktuelle Größe einstellen */
  51.         got = vst_point(handle, asked, &d, &h, &w, &d);
  52.         if ((h == height) && (w == width))
  53.         {
  54.             pt = got;         /* Punktgröße gefunden */
  55.             break;
  56.         }
  57.     }
  58.     return pt;
  59. }
  60.  
  61. #ifndef __MINT__
  62. /*
  63.  * Kennt die Pure/GEM-Lib nicht.
  64. */
  65. static VDIPB    vdipb = {_VDIParBlk.contrl,
  66.                                 _VDIParBlk.intin,
  67.                                 _VDIParBlk.ptsin,
  68.                                 _VDIParBlk.intout,
  69.                                 _VDIParBlk.ptsout};
  70.  
  71. int vdi_str2array(char *src, int *des)
  72. {
  73.     int                len;
  74.     unsigned char    *c;
  75.     
  76.     len = 0;
  77.     c = (unsigned char*)src;
  78.     while (*c != '\0')
  79.     {
  80.         *des++ = *c++;
  81.         len++;
  82.     }
  83.     return len;
  84. }
  85.  
  86. void vqt_real_extent(int handle, int x, int y, char *string, int extent[])
  87. {
  88.     int    i;
  89.  
  90.     i = vdi_str2array(string, _VDIParBlk.intin);
  91.     _VDIParBlk.ptsin[0] = x;
  92.     _VDIParBlk.ptsin[1] = y;
  93.     _VDIParBlk.contrl[0] = 240;
  94.     _VDIParBlk.contrl[1] = 1;
  95.     _VDIParBlk.contrl[3] = i;
  96.     _VDIParBlk.contrl[6] = handle;
  97.     vdi(&vdipb);
  98.     for (i = 0; i<8; i++)
  99.         extent[i] = _VDIParBlk.ptsout[i];
  100. }
  101.  
  102. #endif
  103.